package com.cqw.commontest.stream;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Objects;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-04-08 16:07
 * @Description:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User //implements Comparable<User>
{

    private Long id;

    private String name;

    private Integer age;

    private String email;

    private String hobby;

    private List<String> hobby1;

    public User(Long id, String name, Integer age, String email, String hobby) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.email = email;
        this.hobby = hobby;
    }

    /*@Override
    public int compareTo(User user) {
        return this.getAge() - user.getAge();    // 升序排列，反之降序
        //return user.getAge() - this.getAge();    // 降序排列，反之升序
    }*/


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(id, user.id) && Objects.equals(name, user.name) && Objects.equals(age, user.age) && Objects.equals(email, user.email) && Objects.equals(hobby1, user.hobby1);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, age, email, hobby1);
    }
}
